Skip to content

Conversation

lylezhu2012
Copy link
Contributor

@lylezhu2012 lylezhu2012 commented Aug 27, 2025

Split the structure struct bt_obex into two parts.
Part 1 struct bt_obex, it is the common part and shared by all OBEX sessions which share the same one transport.
Part 2 struct bt_obex_session, it is the dedicated part for each OBEX session.

Add function bt_obex_register() to register the OBEX server with specific uuid.

Add function bt_obex_unregister() to unregister the OBEX server.

@lylezhu2012 lylezhu2012 force-pushed the classic_obex_support_obex_multiple_sessions branch 3 times, most recently from 067dc9d to ce37142 Compare August 28, 2025 08:45
break;
case BT_UUID_SIZE_32:
uuid->uuid.type = BT_UUID_TYPE_32;
uuid->u32.val = sys_get_be16(data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sys_get_be32(data);?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@lylezhu2012 lylezhu2012 force-pushed the classic_obex_support_obex_multiple_sessions branch 2 times, most recently from b6618ee to fe5c811 Compare September 8, 2025 08:56
* Before returning the callback, @ref bt_goep::transport_ops should be initialized with
* valid address of type @ref bt_goep_transport_ops object. The field `mtu` of
* @ref bt_obex::rx could be passed with valid value. Or set it to zero, the mtu will be
* calculated according to @kconfig{CONFIG_BT_GOEP_L2CAP_MTU}.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CONFIG_BT_GOEP_RFCOMM_MTU?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment on lines +210 to +235
/** The OBEX packet header length for PUT and GET request and response. */
#define BT_OBEX_HDR_LEN 3

/** The max PDU data length of OBEX pachet. */
#define BT_OBEX_PDU_LEN(mopl) ((mopl) - BT_OBEX_HDR_LEN)

/** The header length of the OBEX header body/end body. */
#define BT_OBEX_HDR_LEN_OF_HEADER_BODY 3

/** The max remaining length of the buffer if the adding header is body/end body.
*
* It is used to calculate the max sending length when adding the header body data.
* @code{.c}
* uint16_t len = BT_OBEX_PDU_LEN(mopl);
*
* len = MIN(len - buf->len, net_buf_tailroom(buf));
* if (len > BT_OBEX_HDR_LEN_OF_HEADER_BODY) {
* len = BT_OBEX_DATA_LEN_OF_HEADER_BODY(len);
* Calling bt_obex_add_header_body() or bt_obex_add_header_end_body()
* ...
* }
* @endcode
*
* @param len The max remaining length.
*/
#define BT_OBEX_DATA_LEN_OF_HEADER_BODY(len) ((len) - BT_OBEX_HDR_LEN_OF_HEADER_BODY)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the usage of the MACROs in shell\bip.c of #95534 I think it is not easy-to-use by users. I suggest to pass mopl and size_t *add_len to add_header APIs, then the API only put as much data as possible to net buf and return the result.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change is created here b15aeec

}

if (!obex->server_ops->connect) {
if (server->ops->connect == NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (server->ops->connect == NULL) {
if (server->ops == NULL || server->ops->connect == NULL) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not needed. The server->ops has been checked in bt_obex_server_register().

}

if (!obex->server_ops->disconnect) {
if (server->ops->disconnect == NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

}

if (!obex->server_ops->put) {
if (server->ops->put == NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

}

if (!obex->server_ops->get) {
if (server->ops->get == NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

}

if (!obex->server_ops->setpath) {
if (server->ops->setpath == NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

}

if (!obex->server_ops->action) {
if (server->ops->action == NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

}

if (!obex->server_ops->abort) {
if (server->ops->abort == NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

}

int bt_obex_connect(struct bt_obex *obex, uint16_t mopl, struct net_buf *buf)
int bt_obex_server_register(struct bt_obex_server *server, const struct bt_uuid_128 *uuid)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int bt_obex_server_register(struct bt_obex_server *server, const struct bt_uuid_128 *uuid)
int bt_obex_server_register(struct bt_obex* obex, struct bt_obex_server *server, const struct bt_uuid_128 *uuid)

Then application don't needs to set server->obex. and highlight that the registering is for the obex.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the doxygen comments to the function. And also checked the server->obex in the function.

@lylezhu2012 lylezhu2012 force-pushed the classic_obex_support_obex_multiple_sessions branch from fe5c811 to 7d5b771 Compare September 25, 2025 02:06
@zephyrbot zephyrbot requested a review from gzh-terry September 25, 2025 02:08
@lylezhu2012 lylezhu2012 force-pushed the classic_obex_support_obex_multiple_sessions branch from 7d5b771 to 3955c88 Compare September 25, 2025 03:19
Split the structure `struct bt_obex` into two parts.
Part 1 `struct bt_obex`, it is the common part and shared by all OBEX
sessions which share the same one transport.
Part 2 `struct bt_obex_server` and `struct bt_obex_client`. The
`struct bt_obex_server` is used to manage the OBEX session of server
role. The `struct bt_obex_client` is used to manage the OBEX session
of client role.

Add function `bt_obex_server_register()` to register the OBEX server
with specific uuid.

Add function `bt_obex_server_unregister()` to unregister the OBEX
server.

Add function `bt_obex_make_uuid()` to make UUID.

Signed-off-by: Lyle Zhu <[email protected]>
Set the MOPL of RX and TX to `BT_OBEX_MIN_MTU` when registering OBEX
server.

Set the TX MOPL to `BT_OBEX_MIN_MTU` when sending OBEX connection
request.

Check if the MOPL of client exceeds MTU of transport when server
receives the connection request.

Check if the MOPL of server exceeds MTU of transport when client
receives the connection response.

Signed-off-by: Lyle Zhu <[email protected]>
@lylezhu2012 lylezhu2012 force-pushed the classic_obex_support_obex_multiple_sessions branch from 3955c88 to 893e6ad Compare October 9, 2025 07:32
@zephyrbot zephyrbot requested a review from chengkai15 October 9, 2025 07:33
Copy link

sonarqubecloud bot commented Oct 9, 2025

@cfriedt cfriedt merged commit 3ac4f92 into zephyrproject-rtos:main Oct 10, 2025
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants